home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / asmutil / a86v400.zip / MSDOS.8 < prev    next >
Text File  |  1994-12-20  |  2KB  |  75 lines

  1. ;---------------
  2. ;   MSDOS      library module, NOT a standalone program
  3. ;---------------
  4.  
  5. ; This module contains the file-access routines specific to the MSDOS operating
  6. ;   system.
  7.  
  8. ; MCREAT creates a file whose path name is pointed to by DS:DX, giving the file
  9. ;   a standard set of permissions.  Return Carry if there was an error in
  10. ;   creating the file, with AX set to an error number.  Return NoCarry if
  11. ;   successful, with AX set to the open-file number.
  12.  
  13. MCREAT:
  14.   PUSH CX           ; preserve register across call
  15.   MOV CX,0          ; 0-code provides the standard access
  16.   MOV AH,03CH       ; MSDOS function number for CREAT
  17.   INT 33            ; call MSDOS to do the creation
  18.   POP CX            ; restore clobbered register
  19.   MOV BX,AX         ; copy file handle to BX, for convenience
  20.   RET
  21.  
  22.  
  23. ; MREAD reads from the open-file numbered BX, to the CX bytes at DX.  Return
  24. ;   with AX set to the number of bytes actually read.
  25.  
  26. MREAD:
  27.   MOV AH,03FH       ; MSDOS function number for READ
  28. MSDOS:
  29.   INT 33            ; all MSDOS calls go through this interrupt
  30.   RET
  31.  
  32.  
  33. ; MOPEN opens the file whose name is pointed to by DS:DX, with the open-mode
  34. ;   given by the value of AL: 0 for reading, 1 for writing, 2 for both.  Return
  35. ;   Carry if the open failed. Return NoCarry if successful; with AX set to the
  36. ;   open-file number.
  37.  
  38. MOPEN_READ:
  39.   MOV AL,0
  40. MOPEN:
  41.   MOV AH,03DH       ; MSDOS function number for MOPEN
  42.   INT 33            ; all MSDOS calls go through this interrupt
  43.   MOV BX,AX         ; copy file handle to BX, for convenience
  44.   RET
  45.  
  46.  
  47. ; MCLOSE closes the open-file numbered BX.
  48.  
  49. MCLOSE:
  50.   MOV AH,03EH       ; MSDOS function number for CLOSE
  51.   JMP MSDOS         ; jump to call the operating system
  52.  
  53.  
  54. ; MWRITE writes SI bytes from CX to the open-file numbered BX.  Return Carry if
  55. ;   the write failed, with AX set to an error number.
  56.  
  57. OWRITE:             ; alternate entry point for standard output
  58.   MOV BX,1
  59. MWRITE:
  60.   MOV AH,040H       ; MSDOS function number for WRITE
  61.   JMP MSDOS         ; jump to call the operating system
  62.  
  63. EWRITE:             ; alternate entry point for error-console output
  64.   MOV BX,2
  65.   JMP MWRITE
  66.  
  67.  
  68. ; EXIT exits the program back to the invoking process, with a status of AL.
  69.  
  70. GOOD_EXIT:
  71.   MOV AL,0          ; zero value indicates successful program execution
  72. EXIT:
  73.   MOV AH,04CH       ; MSDOS function number for EXIT
  74.   JMP MSDOS         ; jump to call the operating system
  75.